package com.hc.pingtan.controller;


import com.github.pagehelper.PageInfo;
import com.hc.pingtan.model.CommonResult;
import com.hc.pingtan.model.CreateTask;
import com.hc.pingtan.model.GetTaskDetail;
import com.hc.pingtan.model.KekeWitkeyTask;
import com.hc.pingtan.model.KekeWitkeyTaskDetail;
import com.hc.pingtan.model.KekeWitkeyTaskQuery;
import com.hc.pingtan.model.QueryIndustry;
import com.hc.pingtan.model.UpdateTaskStatus;
import com.hc.pingtan.service.IKekeWitkeyTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;


/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author astupidcoder
 * @since 2021-10-25
 */
@Api(tags = "任务需求接口")
@RestController
@RequestMapping("/keke-witkey-task")
public class KekeWitkeyTaskController {
    @Resource
    private IKekeWitkeyTaskService iKekeWitkeyTaskService;

    @ApiOperation(value = "分页获取需求列表", notes = "分页获取需求列表", httpMethod = "POST")
    @PostMapping("pageList")
    public CommonResult<PageInfo<KekeWitkeyTask>> pageList(@RequestBody KekeWitkeyTaskQuery kekeWitkeyTaskQuery) {
        return CommonResult.<PageInfo<KekeWitkeyTask>>builder().result(iKekeWitkeyTaskService.pageList(kekeWitkeyTaskQuery)).build();
    }

    @ApiOperation(value = "创建任务接口", notes = "创建任务接口", httpMethod = "POST")
    @PostMapping("createTask")
    public CommonResult createTask(@RequestBody CreateTask createTask) {
        iKekeWitkeyTaskService.createTask(createTask);
        return CommonResult.builder().build();
    }

    @ApiOperation(value = "获取任务需求详情接口", notes = "获取任务需求详情接口", httpMethod = "POST")
    @PostMapping("getTaskDetail")
    public CommonResult<KekeWitkeyTaskDetail> getTaskDetail(@RequestBody GetTaskDetail getTaskDetail) {
        return CommonResult.<KekeWitkeyTaskDetail>builder().result(iKekeWitkeyTaskService.getTaskDetail(getTaskDetail)).build();
    }

    @ApiOperation(value = "更新任务状态接口", notes = "更新任务状态接口", httpMethod = "POST")
    @PostMapping("updateTaskStatus")
    public CommonResult updateTaskStatus(@RequestBody UpdateTaskStatus updateTaskStatus) {
        iKekeWitkeyTaskService.updateTaskStatus(updateTaskStatus);
        return CommonResult.builder().build();
    }

    @ApiOperation(value = "查询每个栏目的任务列表", notes = "查询每个栏目的任务列表", httpMethod = "POST")
    @PostMapping("queryIndustry")
    public CommonResult<Collection<QueryIndustry>> queryIndustry() {
        return CommonResult.<Collection<QueryIndustry>>builder().result(iKekeWitkeyTaskService.queryIndustry()).build();
    }

    @ApiOperation(value = "获取任务状态接口", notes = "获取任务状态接口", httpMethod = "GET")
    @GetMapping("findTaskStatus")
    public CommonResult<Map<Integer, String>> findTaskStatus() {
        Map<Integer, String> map = new HashMap<>();
        map.put(0, "未付款");
        map.put(1, "待审核");
        map.put(2, "投稿中");
        map.put(3, "任务选稿");
        map.put(4, "发起投票");
        map.put(5, "公示中");
        map.put(6, "交付中");
        map.put(7, "冻结");
        map.put(8, "结束");
        map.put(9, "失败");
        map.put(10, "审核失败");
        map.put(11, "仲裁");
        map.put(13, "交付冻结");
        return CommonResult.<Map<Integer, String>>builder().result(map).build();
    }

}
